package com.iwhalecloud.bss.kite.cucc.service.pos.bcmc.handler.impl;

import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import com.iwhalecloud.bss.kite.cucc.client.dto.pos.KitePosRequestDTO;
import com.iwhalecloud.bss.kite.cucc.common.constant.LocalKeyConsts;
import com.iwhalecloud.bss.kite.cucc.service.pos.bcmc.BcmcPosContext;
import com.iwhalecloud.bss.kite.cucc.service.util.LocalSerialNumUtil;
import com.iwhalecloud.bss.kite.manager.api.IQuerySceneInstService;
import com.iwhalecloud.bss.kite.manager.inst.KiteSceneInst;
import com.ztesoft.bss.common.util.SpringUtil;

/**
 * <Description> <br>
 * 组装报文请求信息节点
 * 
 * @author XXZ<br>
 * @version 1.0<br>
 * @taskId <br>
 * @CreateDate 2020年12月15日 <br>
 * @since R9.0<br>
 * @see com.iwhalecloud.bss.kite.cucc.service.pos.bcmc.handler.impl <br>
 */
@Service
public class BcmcPosRequestHandler extends AbstractBcmcPosHandler{

    @Override
    public void doHandle(BcmcPosContext context) {  
        IQuerySceneInstService querySceneInstService = SpringUtil.getBean(IQuerySceneInstService.class);
        KiteSceneInst sceneInst = querySceneInstService.getSceneInst(context.getSceneInstId());
        if (!StringUtils.equalsAny(sceneInst.getOperType(), LocalKeyConsts.SCENE_OPER_TYPE_ORDER_SIGN,
            LocalKeyConsts.SCENE_OPER_TYPE_TRANSFER_PLAN_MODIFY)) {
            KitePosRequestDTO request = new KitePosRequestDTO();
            request.setSourceOrderId(sceneInst.getCustOrderId());
            request.setSourceMall("24");
            request.setSourceMallName("运营平台");
            request.setVersion(1);
            request.setSerialNo(LocalSerialNumUtil.getOrderSerialNo());

            context.getPosDto().setRequest(request);
        }
    }

}
